import 'package:flutter/material.dart';
import 'package:flutter_app/components/no-record.dart';
import 'package:flutter_app/components/layout.dart';
import 'package:flutter_app/generated/l10n.dart';

class DoubleRecordPage extends StatefulWidget {
  @override
  _DoubleRecordPageState createState() => _DoubleRecordPageState();
}

class _DoubleRecordPageState extends State<DoubleRecordPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  List tabs = List(3);
  @override
  void initState() {
    super.initState();
    // 创建Controller
    _tabController = TabController(length: tabs.length, vsync: this);
  }

  Widget build(BuildContext context) {
    //"全部", "持有中", "已到期"
    tabs = [S.of(context).all, S.of(context).hold, S.of(context).expired];
    return Scaffold(
        appBar: AppBar(
            brightness: Brightness.dark,
            backgroundColor: Colors.blueAccent[400],
            elevation: 0,
            title: HeadTitle(S.of(context).dual_record('BTC-U')),
            centerTitle: true,
            actions: [
              TextButton(
                  onPressed: () {
                    Navigator.pushNamed(context, '/double/reinvest');
                  },
                  //我的复投 auto_invest
                  child: Text(
                    S.of(context).auto_invest,
                    style: TextStyle(color: Colors.white),
                  ))
            ]),
        body: Column(
          children: [
            Container(
              padding: EdgeInsets.symmetric(vertical: 35.0),
              decoration: BoxDecoration(
                color: Colors.blueAccent[400],
                image: DecorationImage(
                    image: AssetImage("assets/images/ic_bch_watermark.png"),
                    alignment: Alignment(1, 0.5),
                    fit: BoxFit.scaleDown,
                    scale: 2.7),
              ),
              child: Center(
                //无在持投资
                child: Text(
                  S.of(context).no_invest,
                  style: TextStyle(color: Colors.white54, fontSize: 16),
                ),
              ),
            ),
            Topradius(
              bgColor: Colors.blueAccent,
              child: TabBar(
                  //生成Tab菜单
                  controller: _tabController,
                  labelColor: Colors.blueAccent,
                  unselectedLabelColor: Colors.grey,
                  indicatorColor: Colors.blueAccent,
                  indicatorSize: TabBarIndicatorSize.label,
                  indicatorWeight: 1.0,
                  tabs: tabs.map((e) => Tab(text: e)).toList()),
            ),
            Expanded(
                child: RefreshIndicator(
              onRefresh: () async {},
              child: NoRecord(),
            ))
          ],
        ));
  }
}
